package com.ray.pojo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

import com.ray.util.AttendanceUtil;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class UserAttendInfoPojo {
	private Integer userId;
	private String userName;
	private String groupName;
	private String className;
	private Integer classId;
	private String attendanceTime;
	private List<Map<String,Object>> clockList;
	//工作时长  这里包括加班时长
	private Long duration;
	/** 加班审批列表 */
	private List<Map<String, Object>> overtimeApprovalList;
	/** 请假审批列表 */
	private List<Map<String, Object>> leaveApprovalList;
	
	public List<Map<String, Object>> getClockList() {
		return clockList;
	}
	
	/**
	 * 将基准时间与打卡时间转换为毫秒
	 * @return
	 * @author 王荣
	 */
	public List<Map<String, Object>> getClockList(boolean b) {
		for(Map<String, Object> clockListMap : clockList) {
			try {
				Object checkTime = clockListMap.get("userCheckTime");
				clockListMap.put("userCheckTime", checkTime == null ? null :new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(checkTime.toString()).getTime());
				clockListMap.put("baseCheckTime", new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(clockListMap.get("baseCheckTime").toString()).getTime());
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
		return clockList;
	}
	
	public List<Map<String, Object>> getOvertimeApprovalList() {
		return overtimeApprovalList;
	}
	
	/**
	 * 将加班审批开始结束时间转换为毫秒
	 * @return
	 * @author 王荣
	 */
	public List<Map<String, Object>> getOvertimeApprovalList(boolean b){
		for(Map<String, Object> overtimeApprovalMap : overtimeApprovalList) {
			try {
				overtimeApprovalMap.put("startTime", new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(overtimeApprovalMap.get("startTime").toString()).getTime());
				overtimeApprovalMap.put("endTime", new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(overtimeApprovalMap.get("endTime").toString()).getTime());
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
		return overtimeApprovalList;
	}

	public List<Map<String, Object>> getLeaveApprovalList() {
		return leaveApprovalList;
	}
	
	/**
	 * 将请假审批开始结束时间转换为毫秒
	 * @return
	 * @author 王荣
	 */
	public List<Map<String, Object>> getLeaveApprovalList(boolean b){
		for(Map<String, Object> leaveApprovalMap : leaveApprovalList) {
			try {
				leaveApprovalMap.put("startTime", new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(leaveApprovalMap.get("startTime").toString()).getTime());
				leaveApprovalMap.put("endTime", new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(leaveApprovalMap.get("endTime").toString()).getTime());
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
		return leaveApprovalList;
	}
	
}
